-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove this-> from decltype #3723
Conversation
The latest version of MSVC doesn't like it, and removing it doesn't seem to harm anything.
Interesting... it fails with g++ 4.8, but appears to work with everything newer (although the builds were canceled so it's hard to tell for sure). |
Looks like a compiler bug, please report to Microsoft. Closing as earlier version of gcc require |
I’ll report the bug, but since it’s in a released version of the compiler that’s active in the Windows-2022 GitHub image, I wouldn’t be surprised if other people started running into this with vcpkg in the near term, so it might be worth an ifdef’ed version of this as a workaround if other people start reporting issues. |
It's unfortunate but we cannot break gcc and this particular case seems to only affect default member initializers in MSVC which can be worked around. Conditionally disabling this will likely cause more problems. |
Given it works without |
Possibly but more likely it's a newer feature (either in the standard or in the implementation). The core of {fmt} only requires a subset of C++11 supported by older compilers including gcc 4.x. |
GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57543 I think we can add macro:
and use it in |
That'll work (although I'd drop "DETAIL_" from the macro name). Not sure why I thought ifdef would be a problem =). |
@vitaut |
I pushed the ifdef version to my branch for this PR, https://github.com/PeterJohnson/fmt/tree/remove-decltype-this (I guess this PR won't actually pick it up unless it's reopened?) |
Reopened |
Merged, thanks. |
Thanks! For completeness, I've reported this bug to Microsoft here: https://developercommunity.visualstudio.com/t/decltypethis-member-fails-with-C203/10523643 |
* Remove this-> from decltype The latest version of MSVC doesn't like it, and removing it doesn't seem to harm anything. * Add ifdef for GCC < 5
The latest version of MSVC doesn't like the use of
this->
in decltype, and removing it from the decltype doesn't seem to harm anything. It's unclear whether this is a bug in MSVC, or a standards-compliant change, given that other compilers don't reject either variant. It feels like this might be a bug in the compiler, as the error messages make it look like MSVC is trying to look up the function in the class where it's being used, rather than the class where it's being defined (e.g. thethis
pointer maybe isn't properly tracked/associated)?An identical patch (wpilibsuite/allwpilib#5948) fixes the build failures we are seeing with current HEAD.
Rough code (full code is https://github.com/calcmogul/allwpilib/blob/6e23e70a8c48266ca25fbb818ce8357dce80ac32/wpilibc/src/main/native/cpp/Preferences.cpp):
On MSVC 19.38.33129 or similar (e.g. using the latest GitHub Windows-2022 image), this errors with the following (full build log at https://github.com/wpilibsuite/allwpilib/actions/runs/6937548373/job/18871818708?pr=5945):